//
// Created by xili on 2024/8/28 21:07.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int balancedStringSplit(string s) {
        int sum = 0;
        int ans = 0;
        for (auto &it: s) {
            sum += it == 'L' ? 1 : -1;
            ans += sum == 0 ? 1 : 0;
        }
        return ans;
    }
};